package com.zlsy.thread.uncaughtexception;

import lombok.extern.slf4j.Slf4j;

/**
 * @author zhouliang
 * @date 2020/03/15
 **/
@Slf4j
public class MyUncaughtExceptionHandler implements Thread.UncaughtExceptionHandler {

    private String name;

    public MyUncaughtExceptionHandler(String name) {
        this.name = name;
    }

    @Override
    public void uncaughtException(Thread t, Throwable e) {
        log.warn("线程异常，中止了，当前线程名字:{},异常堆栈信息:", t.getName(), e);
        System.err.println(name + "捕获了" + t.getName() + "的异常,异常信息：" + e.getMessage());
    }
}
